package com.pdd.service.Impl;

import com.pdd.beans.Comment;
import com.pdd.dao.CommentMapper;
import com.pdd.service.CommentService;
import lombok.Setter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @创建时间: 2018/8/15 - 14:34
 * @编写人员: 丷教皇
 * @文件描述:
 */
@Service
public class CommentServiceImpl implements CommentService {

    @Autowired
    @Setter
    private CommentMapper commentMapper;

    /**
     * 新增评论
     *
     * @param comment 评论对象
     * @return 返回成功失败
     */
    public boolean addComment(Comment comment) {
        return commentMapper.insertComment(comment) > 0;
    }

    /**
     * 按编号删除评论
     *
     * @param id 评论编号
     * @return 返回成功失败
     */
    public boolean delComment(int id) {
        return commentMapper.deleteComment(id) > 0;
    }

    /**
     * 更新评论
     *
     * @param comment 评论对象
     * @return 返回成功失败
     */
    public boolean updComment(Comment comment) {
        return commentMapper.updateComment(comment) > 0;
    }

    /**
     * 按编号查询评论
     *
     * @param id 评论编号
     * @return 返回结果
     */
    public Comment getById(int id) {
        return commentMapper.selectById(id);
    }

    /**
     * 查询所有评论
     *
     * @return 返回结果
     */
    public List<Comment> getAll() {
        return commentMapper.selectAll();
    }
}
